#include "stdafx.h"
#include "AirspaceVolume.h"

std::string AirspaceVolume::Key()
{
	return Name;
}

void AirspaceVolume::ParseDictionary(Dictionary p_Dictionary)
{
	Dictionary::iterator p = p_Dictionary.begin();
	Name = p->second; p++;
	while(p!=p_Dictionary.end())
	{
		AirspaceBaseVolume* t_AirspaceBaseVolume = AirspaceBaseVolumeMap::GetSingleton().GetByKey(p->second); p++;
		if(t_AirspaceBaseVolume!=NULL)
		{
			AirspaceBaseVolumes.push_back(t_AirspaceBaseVolume);
		}
	}
}

bool AirspaceVolume::IsInclude(Point p_Point)
{
	for(std::list<AirspaceBaseVolume*>::iterator p=AirspaceBaseVolumes.begin(); p!=AirspaceBaseVolumes.end(); p++)
	{
		if((*p)->IsInclude(p_Point))
		{
			return true;
		}
	}
	return false;
}

AirspaceVolumeMap::AirspaceVolumeMap() : AdaptationMap<AirspaceVolume>(AIRSPACEVOLUMEADAPTFILENAME)
{
}

std::list<AirspaceVolume*> AirspaceVolumeMap::GetAirspaceVolume(Point p_Point)
{
	std::list<AirspaceVolume*> t_AirspaceVolumes;
	for(std::map<std::string, AirspaceVolume>::iterator p=std::map<std::string, AirspaceVolume>::begin(); p!=std::map<std::string, AirspaceVolume>::end(); p++)
	{
		if(p->second.IsInclude(p_Point))
		{
			t_AirspaceVolumes.push_back(&p->second);
		}
	}
	return t_AirspaceVolumes;
}
